#ifndef CANTHREAD_H
#define CANTHREAD_H

#include <QObject>
#include "./CanLib/ControlCAN.h"
#include <QTime>
#include <QCoreApplication>
#include <QMetaType>
#include <string.h>
#include <QTimer>
#include <QFile>
#include <QTimerEvent>

class canThread : public QObject
{
    Q_OBJECT
public:
    explicit canThread(QObject *parent = nullptr);
    bool openCan();
    void stopCan();
    void closeCan();
    void sendData(int ID,std::vector<int> vec);
    void stCan();
    void stCan1();
    void dataProcess(VCI_CAN_OBJ *vci, DWORD dwRel);

    void timerEvent(QTimerEvent *e);

//    void stoRecData(QString data);
//    void stoSenData(QString data);

    int deviceType;
    int debicIndex;
    int baundRate;
    int debicCom;
    int plnfo;
    bool stopped;
    bool mingling2 = false;
    bool CANConnect = false;//CAN连接状态位

    QString DCDC1_1 ="0000000000000000";
    QString DCDC1_2 ="0000000000000000";
    QString DCDC2_1 ="0000000000000000";
    QString DCDC2_2 ="0000000000000000";
    QString DCDC3_1 ="0000000000000000";
    QString DCDC3_2 ="0000000000000000";

signals:
    void SIGcanclosuc();                                               //CAN断开成功信号
    void SIGtosqlstorecdat(VCI_CAN_OBJ *vci, DWORD dwRel);             //CAN接收数据发送到数据库信号
    void SIGtosqlstosendat(QString xVal,QByteArray data);              //CAN发送数据发送到数据库信号
    void SIGcansuc();                                       //CAN开启、关断状态信号
    void SIGcanopefai();                                               //CAN打开失败信号
    void SIGtomai(QString str);                                        //CAN接收信息显示到主界面信号
    void SIGtomain(QString str);
    void SIGtoSS(VCI_CAN_OBJ *vci, DWORD dwRel);

    void SIGCanOpen();
    void SIGCanClose();
    void SIGCanRec();

    void TCPSendCANData(QString da);

    void Recdata1_1(QString da1);
    void Recdata1_2(QString da1);
    void Recdata2_1(QString da1);
    void Recdata2_2(QString da1);
    void Recdata3_1(QString da1);
    void Recdata3_2(QString da1);

private:
    void sleep(unsigned int msec);



};

#endif // CANTHREAD_H
